package com.maxd.modules.redPacket.service.impl;

import com.maxd.error.Result;
import com.maxd.error.ResultUtil;
import com.maxd.modules.redPacket.dao.StoreroomJpaRepository;
import com.maxd.modules.redPacket.dao.StoreroomRepository;
import com.maxd.modules.redPacket.entity.Storeroom;
import com.maxd.modules.redPacket.service.IRedPacketService;
import com.maxd.modules.redPacket.service.IStoreroomService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 *  文案或链接
 */
@Service
public class StoreroomServiceImpl implements IStoreroomService {

    @Autowired
    private StoreroomJpaRepository storeroomJpaRepository;
    @Autowired
    private StoreroomRepository storeroomRepository;

    @Override
    public Result insertStoreroom(Storeroom storeroom){
        storeroomJpaRepository.save(storeroom);
        return ResultUtil.success();
    }

    @Override
    public Result selectStoreroomPageByClassify(Integer page,Integer size,Integer classify,String content){
        Pageable pageable = PageRequest.of(page, size);
        return ResultUtil.success(storeroomRepository.selectStoreroomPageByClassify(pageable,classify,content));
    }

    @Override
    public List<Storeroom> selectStoreroomListByClassify(Integer classify){
        return storeroomRepository.selectStoreroomListByClassify(classify);
    }


    @Override
    public Result deleteStoreroomById(Long id){
        storeroomJpaRepository.deleteById(id);
        return ResultUtil.success();
    }







}
